package com.deng.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    //队列名
    public final static String ES_QUEUE="es_queue";
    //交换机名
    public final static String ES_EXCHANGE="es_exchange";
    //绑定key
    public final static String ES_BIND_KEY="es_exchange";
    //队列
    @Bean
    public Queue exQueue(){
        return new Queue(ES_QUEUE);
    }
    //交换机
    @Bean
    DirectExchange exchange(){
        return new DirectExchange(ES_EXCHANGE);
    }
    //绑定队列到交换机
    @Bean
    Binding binding(Queue exQueue,DirectExchange exchange){
        return BindingBuilder.bind(exQueue).to(exchange).with(ES_BIND_KEY);
    }
}
